/**
 * 
 */
package com.angel.configuration.initializer.impl;

import com.angel.architecture.persistence.beans.ConfigurationParameter;
import com.angel.common.helpers.ReflectionHelper;
import com.angel.configuration.initializer.ConfigurationInitializer;
import com.angel.webapp.application.ApplicationUserGenerators;

/**
 * @author William
 *
 */
public class UserGeneratorsInitializer extends ConfigurationInitializer{

	private static final String USER_GENERATORS_AREA_NAME = "UserGenerators";

	@Override
	public boolean appliesConfiguration(ConfigurationParameter cp) {
		return cp != null && cp.isForParameterArea(USER_GENERATORS_AREA_NAME);
	}
	
	@Override
	public void addConfiguration(ConfigurationParameter cp) {
		Class<?> userGeneratorClass = ReflectionHelper.getClassFrom(cp.getStringValue());
		ApplicationUserGenerators.createInstance().addUserGenerator(cp.getName(), userGeneratorClass);
	}

}
